more
authorJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 20:31:09 +0000 (16:31 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 4 Sep 2025 20:31:09 +0000 (16:31 -0400)
Annex/Link.hs
doc/bugs/35_failed_tests_on_beegfs/comment_6_172a92bf49be25355dda3f88b377a6f4._comment

index 6cef911a11969922ce7da41fda0faed1c2ee80a1..480a00ce25cf7869af96e7eb7670ab9d193573df 100644 (file)
@@ -36,6 +36,7 @@ import Utility.FileMode
 import Utility.InodeCache
 import Utility.Tmp.Dir
 import Utility.CopyFile
+import Utility.OpenFd
 import qualified Database.Keys.Handle
 import qualified Utility.RawFilePath as R
 import qualified Utility.FileIO as F
@@ -447,8 +448,9 @@ isPointerFile f = catchDefaultIO Nothing $
 #else
 #if MIN_VERSION_unix(2,8,0)
        let open = do
-               fd <- openFd (fromOsPath f) ReadOnly 
-                       (defaultFileFlags { nofollow = True, cloexec = True })
+               fd <- openFdWithMode (fromOsPath f) ReadOnly Nothing
+                       (defaultFileFlags { nofollow = True })
+                       (CloseOnExecFlag True)
                fdToHandle fd
        in bracket open hClose readhandle
 #else
index 4d33caa11d8a6941a1750ef70ea97a9f3a6a1942..8ba69239de9eaf70dd82dddcd6c26125e4931293 100644 (file)
@@ -3,11 +3,14 @@
  subject="""comment 6"""
  date="2025-09-04T18:24:33Z"
  content="""
-Note that `openFile` is not the only one that would need to be dealt with.
-Also `withFile`, `openBinaryFile`, and `withBinaryFile`.
+`openFile` is not the only one that would need to be dealt with.
+Also `withFile`, `openBinaryFile`, `withBinaryFile`, `appendFile`,
+and `openTempFile`, `readFile, and `writeFile` (including `L.` versions).
 
-And, since none of those provide a way to set CloseOnExec, they would have
-to be changed to use `openFd` with CloseOnExec, and then mkHandleFromFD.
+Since none of those provide a way to set CloseOnExec, they would have
+to be changed to be implemented using `openFd` with CloseOnExec, and
+then mkHandleFromFD. Or rewritten to use
+<https://hackage.haskell.org/package/file-io-0.1.5/docs/src/System.File.OsPath.Internal.html#openFileWithCloseOnExec>
 
 I have checked and none of those are ever used to create a handle that is
 intentionally passed to a child process. The only uses of `handleToFd`
@@ -17,5 +20,7 @@ versions of all of those.
 
 Also there are a few uses of `openFd` that don't set CloseOnExec.
 
-And possibly also some libraries might open files, I don't know.
+There is also the problem that any haskell library that does anything
+with a file might use any of the above internally without setting
+close-on-exec.
 """]]